interface LabelledVale{
    label:string;
    number:number;
}

function printLable(laveObj : LabelledVale){
    console.log(laveObj.label);
    console.log(laveObj.number);
}

let muyObj = {number:10,label:";kdsjr"};//必须传接口声明的类型，类型检查器不会去检查属性的顺序

// printLable(muyObj);

interface SquareConfig {//接口可选参数
  color?: string;
  width?: number;
  readonly x: number;//加readonly 就是只读属性
}

function createSquare(config:SquareConfig) : {colors:string;areas:number}{//实现接口，返回color，string类型和area，number类型
    let newSquare = {colors:"white",areas:1000};
    if(config.color){
        newSquare.colors = config.color;
    }
    if(config.width){
        newSquare.areas = config.width;
    }
    // console.log(config.x);
    return newSquare;
}

let any = createSquare({color:'sefsrgds',x:50});
// console.log(any);

// 数组创建后再也不能被修改
let ab: number[] = [1, 2, 3, 4];
let ro: ReadonlyArray<number> = ab;
// ro[0] = 12; // error!
// ro.push(5); // error!
// ro.length = 100; // error!
// a = ro; // error!  但是可以用类型断言重写as

interface clockTnt{
    curentTime:Date;
    setTime(d:Date);
}

class Claock implements clockTnt{
    constructor(h:number,m:number){}
    curentTime:Date;
    setTime(d:Date){
        this.curentTime = d;
    }
    getTime(){
        return this.curentTime;
    }
}
let time = new Date();
let sdf = new Claock(4,6);
sdf.setTime(time);
console.log(sdf.getTime());
// 一个接口可以继承多个接口，创建出多个接口的合成接口。
interface Shape {
    color: string;
}

interface PenStroke {
    penWidth: number;
}

interface Square extends Shape, PenStroke {
    sideLength: number;
}

let square = <Square>{};
square.color = "blue";
square.sideLength = 10;
square.penWidth = 5.0;








